﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;

namespace AppearanceDetectionStation
{
    public partial class FormMain : Form
    {
        public FormMain()
        {
            InitializeComponent();
        }
        public static string neibuma;
        public static bool goSelect;
        public static bool photoDone;
        public static bool retry;
        public static bool delete;

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void panel1_MouseDown(object sender, MouseEventArgs e)
        {

        }
        //9宫格显示
        private void 宫格显示ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CloseForm();
            OpenForm(new Form9());
        }
        //16宫格显示
        private void 宫格显示ToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            CloseForm();
            OpenForm(new Form16());
        }
        #region 操作窗体
        /// <summary>
        /// 打开窗体，将页面嵌入到主窗体
        /// </summary>
        /// <param name="form"></param>
        private void OpenForm(Form form)
        {
            //将当前子窗体设置成非顶级控件
            form.TopLevel = false;
            //设置窗体最大化
            form.WindowState = FormWindowState.Maximized;
            //设置窗体无边框
            form.FormBorderStyle = FormBorderStyle.None;
            //设置窗体嵌入容器
            form.Parent = this.panel1;
            form.Show();
        }
        /// <summary>
        /// 关闭窗体，将容器内窗体移除
        /// </summary>
        private void CloseForm()
        {
            //遍历这个容器里面的所有控件，找出窗体对象
            foreach (Control item in this.panel1.Controls)
            {
                if (item is Form)
                {
                    Form form = (Form)item;
                    form.Close();
                    //移除
                    this.panel1.Controls.Remove(item);
                }
            }
        }

        #endregion

        private void 宫格显示ToolStripMenuItem2_Click(object sender, EventArgs e)
        {
            CloseForm();
            OpenForm(new Form12());
        }
    }
}
